<?php
namespace Mapi\Controller\V1_1;
use Mapi\Controller\BaseController;
class SearchController extends BaseController
{

	public function delscore()
	{
		$openid = I('post.weixinid');
		//$openid =1;
		if(strlen($openid)<10){
			$this->apiReturn(0,'','weixinid error');
			echo 'weixinid error';
		}

		$sql = "delete from chsi_stud_score where weixinid='".$openid."'";

		D('StudScore')->execute($sql);
		$this->apiReturn(1,$redata,'ok');

	}
	public function getQrcode()
	{
		$openid = I('post.weixinid');
		//$openid =1;
		if(strlen($openid)<10){
			$this->apiReturn(0,'','weixinid error');
			//echo 'weixinid error';
		}
		$map['data_time'] = date('Y',CURRENT_TIME);
		$map['weixinid'] = $openid;
		$info =  D('StudScore')->where($map)->find();
		$zyxw=json_decode($this->_menu['conf_qrimgs'],true);
		$data = $zyxw[$info['yjxkdm']];

		$redata[0]['qrcode'] =$data['imgpath'];// "http://img.kaoyanzhoubao.cn/test1.png";
		$redata[0]['zyxw'] =$data['name']; //"测试专业";
		$this->apiReturn(1,$redata,'ok');

	}
	/*
	 * 学校联想
	 * */
	public function getSchool()
	{
		$return_data = array('Search' => 'Search');
		$word = I('post.scname');
		//$word = "北京";
		$map['scname'] = $word;
		$list = D('school')->where($map)->limit(10)->select();

		if($list){

			$data['tag']="1";
			$data['data']=$list;

		} else{
			$map['scname'] = array('like',"%".$word."%");
			$list = D('school')->where($map)->limit(10)->select();
			$data['tag']="0";
			$data['data']=$list;

		}
		$this->apiReturn(1,$data,'ok');

	}

	//学位类别
	public function getMldm()
	{

		$mldm=json_decode($this->_menu['mldm'],true);
		$redata[0]['name'] = '专业学位';
		$redata[0]['data'][0] = array('mc'=>'专业学位','dm'=>'zyxw');
		$redata[1]['name'] = '学术学位';
		$redata[1]['data'] = $mldm;
		$this->apiReturn(1,$redata,'ok');

	}

	//专业类别获取
	public function getYjxkdm()
	{
		$word = I('post.mldm');
		//$word = '01';
		if($word == 'zyxw'){
			$mldm=json_decode($this->_menu['zyxw'],true);
		} else {
			$temp=json_decode($this->_menu['XSLY'],true);
			foreach($temp as $key=>$val)
			{
				if($val['mc'] == $word){
					$mldm=$val['data'];
				}
			}
		}
		$redata=$mldm;
		$this->apiReturn(1,$redata,'ok');
	}


	//专业科目类别获取
	public function getZymc()
	{
		$word = I('post.mldm');
		$Yjxkdm = I('post.Yjxkdm');

		//$word='zyxw';
		//$Yjxkdm ='1351';

		$ope= D('ZyMenu');
		$map['mldm'] = $word;
		$map['yjxkdm'] = $Yjxkdm;

		$sql = "SELECT *FROM chsi_zy_menu WHERE  mldm='".$word."' AND  yjxkdm  ='".$Yjxkdm."'  GROUP BY zymc order by id";

		$zyleibie = $ope->query($sql);
		//$tt[0] = $zyleibie;
		$this->apiReturn(1,$zyleibie,'ok');
	}


	//专业科目类别获取
	public function getXxfs()
	{
		$zyleibie[0]['name'] = "全日制";
		$zyleibie[0]['value'] = "1";
		$zyleibie[1]['name'] = "非全日制";
		$zyleibie[1]['value'] = "2";
		$this->apiReturn(1,$zyleibie,'ok');
	}


	//专业科目类别获取
	public function geFrom()
	{
		$zymc = I('post.zyxw');
		//$zymc ="新闻与传播";
		$zyleibie[0]['name'] = "政治";
		$zyleibie[0]['value'] = "class1";
		$zyleibie[0]['max'] = "100";
		$zyleibie[1]['name'] = "英语";
		$zyleibie[1]['value'] = "class2";
		$zyleibie[1]['max'] = "100";

		if(!D('Noshuxue')->kaoshuxue($zymc) ){
			$zyleibie[2]['name'] = "数学";
		}else {
			$zyleibie[2]['name'] = "专业一";
		}
		$zyleibie[2]['value'] = "class3";
		$zyleibie[2]['max'] = "500";
		$zyleibie[3]['name'] = "专业二";
		$zyleibie[3]['value'] = "class4";
		$zyleibie[3]['max'] = "500";
		$zyleibie[4]['name'] = "专业其他";
		$zyleibie[4]['value'] = "class5";
		$zyleibie[4]['max'] = "500";
		$this->apiReturn(1,$zyleibie,'ok');
	}

}